<!DOCTYPE HTML>
<html lang="en">
<head>
<title>StrLen() / StringLen - Syntax &amp; Usage | AutoHotkey</title>
<meta name="description" content="The StrLen function and StringLen command retrieve the count of how many characters are in a string." />
<meta name="ahk:equiv-v2" content="commands/StrLen.htm" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>StrLen() / StringLen</h1>

<p>Retrieves the count of how many characters are in a string.</p>

<h2 id="function">StrLen()</h2>

<pre class="Syntax">Length := <span class="func">StrLen</span>(String)</pre>
<h3>Parameters</h3>
<dl>

  <dt>String</dt>
  <dd><p>The string to be measured.</p></dd>

</dl>

<h3>Return Value</h3>
<p>This function returns the length of the string.</p>

<h3>Examples</h3>
<pre class="NoIndent">InputVar := "The Quick Brown Fox Jumps Over the Lazy Dog"
MsgBox % &quot;The length of InputVar is &quot; . StrLen(InputVar) <em>; Result: 43</em></pre>
<h2 id="command">StringLen</h2>
<p class="warning"><strong>Deprecated:</strong> This command is not recommended for use in new scripts. Use the <a href="#function">StrLen</a> function instead.</p>

<pre class="Syntax"><span class="func">StringLen</span>, OutputVar, InputVar</pre>
<h3>Parameters</h3>
<dl>

  <dt>OutputVar</dt>
  <dd><p>The name of the variable in which to store the length.</p></dd>

  <dt>InputVar</dt>
  <dd><p>The name of the variable whose contents will be measured. Do not enclose the name in percent signs unless you want the <em>contents</em> of the variable to be used as the name.</p>
  </dd>

</dl>

<h3>Examples</h3>
<pre class="NoIndent">StringLen, Length, InputVar
MsgBox, The length of InputVar is %Length%.</pre>

<h2>Remarks</h2>
<p>If <em>String</em> or <em>InputVar</em> is a variable to which <a href="../misc/Clipboard.htm#ClipboardAll">ClipboardAll</a> was previously assigned, StrLen() or StringLen will report its total size.</p>
<h2>Related</h2>
<p><a href="IfInString.htm">IfInString</a>, <a href="StringGetPos.htm">StringGetPos</a>, <a href="StringMid.htm">StringMid</a>, <a href="StringTrimLeft.htm">StringTrimLeft</a>, <a href="StringTrimLeft.htm">StringTrimRight</a>, <a href="StringLeft.htm">StringLeft</a>, <a href="StringLeft.htm">StringRight</a>, <a href="StringLower.htm">StringLower</a>, <a href="StringLower.htm">StringUpper</a>, <a href="StringReplace.htm">StringReplace</a></p>

</body>
</html>
